package vistas;
import java.awt.BorderLayout;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;

import javax.swing.WindowConstants;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import javax.swing.SwingUtilities;

public class JFListadoExistencia extends javax.swing.JFrame {
	private JButton jBCargar;
	private JPanel jPanel1;
	private JScrollPane jScrollPane1;
	private JButton jBLimpiar;
	private JTable jTablaIngredientes;

	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				JFListadoExistencia inst = new JFListadoExistencia();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public JFListadoExistencia() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			this.setTitle("Laboratorio   Burger");
			{
				jBCargar = new JButton();
				getContentPane().add(jBCargar);
				jBCargar.setText("Cargar Ingredientes");
				jBCargar.setBounds(568, 33, 153, 33);
			}
			{
				jPanel1 = new JPanel();
				getContentPane().add(jPanel1);
				jPanel1.setLayout(null);
				jPanel1.setBounds(12, 25, 550, 333);
				jPanel1.setBorder(BorderFactory.createTitledBorder("Listado de Existencia de Ingredientes"));
				jPanel1.setLayout(null);
				{
					jScrollPane1 = new JScrollPane();
					jPanel1.add(jScrollPane1);
					jScrollPane1.setBounds(11, 20, 529, 302);
					tabla();
				}
			}
			{
				jBLimpiar = new JButton();
				getContentPane().add(jBLimpiar);
				jBLimpiar.setText("Limpiar");
				jBLimpiar.setBounds(568, 86, 153, 31);
			}
			pack();
			this.setSize(752, 419);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}
	
	
	public void addListener(ActionListener actionListener) 
	{
		this.jBCargar.addActionListener(actionListener);
		this.jBLimpiar.addActionListener(actionListener);
	}
	
	public void setResultados(AbstractTableModel abstractTableModel)
	    {
		jTablaIngredientes.setModel(abstractTableModel);
	    }
	
	public void tabla(){
		
			TableModel jTablaIngredientesModel = 
				new DefaultTableModel(
						new String[][] { },
						new String[] { "Codigo", "Ingrediente", "Existencia" });
			jTablaIngredientes = new JTable();
			jScrollPane1.setViewportView(jTablaIngredientes);
			jTablaIngredientes.setModel(jTablaIngredientesModel);
		
	}
      public void limpiar(){
    	  tabla();
      }
}
